<template>
<div>
    <div style="margin: 20px 10px 20px 10px" class="van-safe-area-bottom">
      <p>{{userId}}</p>
      <van-address-list
          v-model="chosenAddressId"
          :list="addressList"
          @add="onAdd"
          @edit="onEdit"
      />
    </div>
</div>
</template>

<script>
export default {
  name: "AddressList",
  props: {
    userId:{
      default:''
    }
  },
  data(){
    return{
      chosenAddressId: 1,
      addressList: [],
    }
  },
  watch:{
    userId:{
      handler:function (newValue, oldValue) {
      //  this.$toast.success(this.userId);
        this.addressList=[{
          id: '1',
          name: '张三',
          tel: '13000000000',
          address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
          isDefault: true,
        },
          {
            id: '2',
            name: '李四',
            tel: '1310000000',
            address: '浙江省杭州市拱墅区莫干山路 50 号',
          },]
      }
    }

  },
  created() {
    this.addressList=[{
      id: '1',
      name: '张三',
      tel: '13000000000',
      address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
      isDefault: true,
    },
      {
        id: '2',
        name: '李四',
        tel: '1310000000',
        address: '浙江省杭州市拱墅区莫干山路 50 号',
      },]
  },
  methods:{
    onAdd(){
      this.$toast.success('onAdd');
    },
    onEdit(){
      this.$toast.success('onEdit');
    },
  }
}
</script>

<style scoped>

</style>